using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace ARF.Web.Controls
{
    public class ListViewXml : ListXml
    {
        private string _viewName;

        public string ViewName
        {
            get { return _viewName; }
            set { _viewName = value; }
        }

        protected override void BuildXml()
        {
            try
            {
                SPListItemCollection oResults = null; SPView oView = null;

                if (ViewName.StartsWith("{"))
                    oView = ContextList.Views[new Guid(ViewName)];
                else
                    oView = ContextList.Views[ViewName];

                oResults = ContextList.GetItems(oView);

                XmlAsObject = Utility.Utility.CleanXml(oResults.Xml);
            }
            catch (Exception ex)
            {
                Log.Trace(ex);
                XmlAsString = "<Error>" + ex.Message + "</Error>";
            }
        }
    }
}
